package cn._51doit.flink.day02.transformations;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * 对DataStream中对应的数据进行过滤
 *
 * 使用lambda表达式
 *
 */
public class FilterDemo2 {

    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //spark
        //hive
        //hadoop
        DataStreamSource<String> lines = env.socketTextStream("localhost", 8888);

        //过滤掉以h开头的数据
        SingleOutputStreamOperator<String> filtered = lines.filter(line -> !line.startsWith("h"));

        filtered.print();

        env.execute();
    }

}
